/**
 * 
 */
$(function() {
	$('#btnBack').click(function() {
		window.location = "/group3/ListTrustRegion.html";
	});
	
	$("#TabDetailRegion").easyResponsiveTabs({           
		type: 'default', //Types: default, vertical, accordion           
		width: 'auto', //auto or any width like 600px
		fit: false,   // 100% fit in a container
		closed: 'accordion', // Start closed if in accordion view
		activate: function(event) {  }// Callback function if tab is switched                            
        });

	$('#btnInactive').click(
			function() {
				var reName = $('#regionName').val();
				if (reName == "") {
					$('#nameError').html("This field is required");
					return false;
				}

				// send ajax to inactive this region
				$.ajax({
					type : "POST",
					url : "/group3/amendInactive",
					data : "countryName=" + $('#countryName').val()
							+ "&regionName=" + $('#regionName').val()
							+ "&description=" + $('#description').val(),
					dataType : "json",
					success : function(data) {
						$('#msg').html(data.message);
					}
				});
			});

	$('#btnSave').click(
			function() {
				var reName = $('#regionName').val();
				if (reName == "") {
					$('#nameError').html("This field is required");
					return false;
				}

				// send ajax to save data
				$.ajax({
					type : "POST",
					url : "/group3/save",
					data : "countryName=" + $('#countryName').val()
							+ "&regionName=" + $('#regionName').val()
							+ "&description=" + $('#description').val(),
					dataType : "json",
					success : function(data) {
						$('#msg').html(data.message);
					}
				});
			});

	$('#regionName').click(function() {
		$('#nameError').html("");
	});
});